added a simple program to export files in .vdb format#148
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #148 +/- ##
==========================================
+ Coverage 89.69% 90.03% +0.33%
==========================================
Files 5 6 +1
Lines 844 953 +109
Branches 108 126 +18
==========================================
+ Hits 757 858 +101
- Misses 52 58 +6
- Partials 35 37 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@orbeckst , please review the OpenVDB.py file. After that, I will add some more test covering all the missing parts |
|
Thank you for contribution. I’m currently on holidays and will come back to reviewing open source contributions in the new year. Am 12/27/25 um 03:16 schrieb Shreejan Dolai ***@***.***>:spyke7 left a comment (MDAnalysis/GridDataFormats#148)
@orbeckst , please review the OpenVDB.py file. After that, I will add some more test covering all the missing parts
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
orbeckst
left a comment
There was a problem hiding this comment.
Thank you for your contribution. Before going further, can you please try your own code and demonstrate that it works? For instance, take some of the bundled test files such as 1jzv.ccp4 or nAChR_M2_water.plt, write it to OpenVDB, load it in blender, and show an image of the rendered density?
Once we know that it's working in principle, we'll need proper tests (you can look at PR #147 for good example of minimal testing for writing functionality).
| Fixes | ||
|
|
||
| * Adding openVDB formats (Issue #141) |
There was a problem hiding this comment.
not a fix but an Enhancement – put it into the existing 1.1.0 section and add you name there.
There was a problem hiding this comment.
In the CHANGELOG, this PR and issue are in the 1.1.0 release, so should I add my name in the 1.1.0 release or remove those lines and put them in the new section?
There was a problem hiding this comment.
Yes, now move it to the new section above since we released 1.1.0.
| for i in range(self.grid.shape[0]): | ||
| for j in range(self.grid.shape[1]): | ||
| for k in range(self.grid.shape[2]): | ||
| value = float(self.grid[i, j, k]) | ||
| if abs(value) > threshold: | ||
| accessor.setValueOn((i, j, k), value) |
There was a problem hiding this comment.
This looks really slow — iterating over a grid explicitly. For a start, you can find all cells above a threshold with numpy operations (np.abs(g) > threshold) and then ideally use it in a vectorized form to set the accessor.
|
fixed the CHANGELOG and OpenVDB.py. I didn't get the time to work on the blender part due to exams. I will surely try do it! |
|
Good that you're able to load something into Blender. From a first glance I don;t recognize what I'd expect but this may be dependent on how you render in Blender. As I already said on Discord: Try to establish yourself what "correct" means. Load the original data in a program where you can reliably look at it. ChimeraX is probably the best for looking at densities; it can definitely read DX. Btw, the M2 density should look similar to the blue "blobs" on the cover of https://sbcb.bioch.ox.ac.uk/users/oliver/download/Thesis/OB_thesis_2sided.pdf |
|
Mentioned in the Discord but also bringing up here: In your current examples (most obvious with the pore) is that the axis is flipped so that X is "up" compared to atomic coordinates which would have Z as up. |
Thank you for the update! will try to fix this |
|
Ideally we would see this alongside the atoms or density from MN as well - to double check alignment because you might also need to flip one of the X or Y axes. |
|
The scales might be different (larger or smaller by factors of 10) but you can just scale inside of Blender by that amount to align the scales, but we want to be double checking alignemnt and axes. |
|
I have first of all added the MolecularNode add-on as given in the https://github.com/BradyAJohnston/MolecularNodes, and imported the 1jzv.pdb. After that import the .vdb file and there was difference in size of two. So I made the size the .pdb bigger. The centers of both of them are same and I didn't flipped any of the axes in the ss provided. I wrote a small blender py script to compare bounding boxes of the pdb and vdb objects to verify centroids, extents and axis alignment- output - The centroids are almost same I guess... |
|
@spyke7 It's still not 100% clear from your screenshots - can you import with the pore instead as that is more clear? And when you are taking a screenshot it would be more helpful to have the imported density in the centre of the screen rather than mostly empty space. |
|
Looks like you are attempting a standalone export to |
|
If this functionality can be added directly to GDF then we can also take advantage of that in MN going forwards. |
Agreed. In addition to exporting to |
This is a good point and something to consider as well. As far as I am aware Blender / MN (and other 3D animation packages) might be the only ones who use If there is anything out there that does take |
Yeah, I was looking into other comments, and will create the tests as required. |
This looks good to me. I am ok with proceeding as needed. A few minor points:
Thanks |
|
@orbeckst pls check the test functions when you are free. I have added new tests for from_grid and native and covered the points given by @PardhavMaradani . |
orbeckst
left a comment
There was a problem hiding this comment.
I only have minor final requests, please see comments.
Thanks for adding the tests for from_grid() and native — I think this also addresses directly one of @PardhavMaradani's points.
Co-authored-by: Oliver Beckstein <orbeckst@gmail.com>
Co-authored-by: Oliver Beckstein <orbeckst@gmail.com>
orbeckst
left a comment
There was a problem hiding this comment.
Thank you for addressing my comments. Looks ready to be merged!
|
@PardhavMaradani I'd appreciate your final review of this PR if you have time. |
PardhavMaradani
left a comment
There was a problem hiding this comment.
This looks pretty good to me. Thanks
orbeckst
left a comment
There was a problem hiding this comment.
The OpenVDB page does not show up in the docs. Eg look at https://griddataformats--148.org.readthedocs.build/en/148/gridData/formats.html and notice that the link to OpenVDB in the table does not resolve and the module page is not included in formats.
Please check how the docs are build and fix.
orbeckst
left a comment
There was a problem hiding this comment.
Sorry, there are still a few doc issues. Please check the rendered docs. Thanks.
| pickle (use :meth:`Grid.load` to restore); :meth:`Grid.save` | ||
| is simpler than ``export(format='python')``. | ||
| vdb | ||
| :mod:`OpenVDB` |
There was a problem hiding this comment.
Link does not resolve https://griddataformats--148.org.readthedocs.build/en/148/gridData/core.html#gridData.core.Grid.export
(same for the other two for dx and mrc)
There was a problem hiding this comment.
All the links work, but for showing the classes and functions for OpenVDB, I added
:members:
:undoc-members:
:show-inheritance:
but then DownCastTo and OpenVDBfield is shown in format.rst
Can you please go through it once, and how to fix it?
Thanks
| MRC | ||
| :mod:`mrcfile.mrcinterpreter.MrcInterpreter` MRC/CCP4 format | ||
| VDB | ||
| :class:`openvdb.GridBase` OpenVDB format (e.g., FloatGrid, DoubleGrid) |
There was a problem hiding this comment.
Link does not resolve https://griddataformats--148.org.readthedocs.build/en/148/gridData/core.html#gridData.core.Grid.convert_to
(neither do the ones for DX and MRC)
|
|
||
| g = Grid("data.dx") | ||
| g.export("data.vdb") | ||
|
|
There was a problem hiding this comment.
Add a note how you can use Grid.convert_to("VDB") to get the field.
Also mention that .native gives the underlying openvdb object.
orbeckst
left a comment
There was a problem hiding this comment.
The fixes to make the docs render and link correctly are good.
I updated the docs a bit (will merge my edits) and then it should be ready to be merged.
|
Thank you for your major contribution @spyke7 ! Your big PR is merged! 🎉 |










Hi @orbeckst
I have added
OpenVDB.pyinside gridData that simply export files in.vdbformat. Also I have addedtest_vdb.pyinside tests and it successfully passes.fix #141
Required Libraries -
openvdb
conda install -c conda-forge openvdbThere are many things that need to be updated like docs, etc, but I have just provided the file and test so that you can review it, and I can fix the problems. Please let me know if anything needs to be changed and updated.